package com.example.rbacmanage.service.app.impl;

import com.example.rbacmanage.annotation.PermissionRange;
import com.example.rbacmanage.entity.app.Points;
import com.example.rbacmanage.mapper.app.PointsMapper;
import com.example.rbacmanage.service.app.PointsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PointsServiceImpl implements PointsService {
    @Autowired
    private PointsMapper pointsMapper;
    @Override
    public void save(Points points) {
        points.setCreateTime(new Date());
        pointsMapper.insert(points);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id : ids) {
            pointsMapper.del(id);
        }
    }

    @Override
    public void update(Points points) {
        pointsMapper.update(points);
    }

    @Override
    public List<Points> getAll(Points points) {
        return pointsMapper.list(points);
    }

    @Override
    public PageInfo<Points> getPage(Points points) {
        PageHelper.startPage(points.getPage(),points.getLimit());
        return new PageInfo<>(getAll(points));
    }

    @Override
    public Points getById(Long id) {
        return pointsMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(Points points) {
        return pointsMapper.count(points);
    }
}
